/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.factory.server.dto;

import java.math.BigInteger;

/**
 *
 * @author milos
 */
public class EdgeDTO implements Comparable<EdgeDTO> {

    Integer source;
    Integer target;
    double cost;

    public EdgeDTO(Integer source, Integer target, double cost) {
        this.source = source;
        this.target = target;
        this.cost = cost;
    }

    public Integer getSource() {
        return source;
    }

    public void setSource(Integer source) {
        this.source = source;
    }

    public Integer getTarget() {
        return target;
    }

    public void setTarget(Integer target) {
        this.target = target;
    }

    public double getCost() {
        return cost;
    }

    public void setCost(double cost) {
        this.cost = cost;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof EdgeDTO)) {
            return false;
        }
        EdgeDTO edge = (EdgeDTO) obj;
        if (edge.getSource().equals(this.source) && edge.getTarget().equals(this.target) && edge.getCost() == this.cost) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 71 * hash + (this.source != null ? this.source.hashCode() : 0);
        hash = 71 * hash + (this.target != null ? this.target.hashCode() : 0);
        hash = 71 * hash + (int) (Double.doubleToLongBits(this.cost) ^ (Double.doubleToLongBits(this.cost) >>> 32));
        return hash;
    }

    public boolean isSameOppositeEdge(EdgeDTO edge) {
        if (edge.getSource().equals(this.target) && edge.getTarget().equals(this.source) && edge.getCost() == this.cost) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public String toString() {
        return source+" "+target+" "+cost;
    }
    
        public int compareTo(EdgeDTO o) {
        if (this.getCost() > o.getCost()) {
            return 1;
        } else if (this.getCost() < o.getCost()) {
            return -1;
        } else {
            return 0;
        }
    }
}
